package com.panda.common.interceptor;

import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 拦截器
 *
 */
@Component
public class CheckTokenInterceptor implements HandlerInterceptor {
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		logger.info("exec CheckTokenInterceptor's preHandle method...");
		Map<String, String[]> parameterMap = request.getParameterMap();
		Set<Entry<String, String[]>> entrySet = parameterMap.entrySet();
		Iterator<Entry<String, String[]>> iterator = entrySet.iterator();
		String requestURI = request.getRequestURI();
		System.out.println("当前访问的是:" + requestURI);
		while (iterator.hasNext()) {
			Entry<String, String[]> next = iterator.next();
			System.out.println(next.getKey() + ":" + Arrays.toString(next.getValue()));
		}
		return true;
	}
}
